<?php


class Apiindex extends ApiBase {
	
   public function index(){
   	$data['video']=$this->db->select('url')->get('video')->row_array();
   	$data['video']='https://'.$_SERVER['HTTP_HOST'].'/'.$data['video']['url'];
   	
   	$data['list']=$this->getGoods();
   	
   	
   	$data['contact']=$this->db->select('phone,time')->get('wxapp')->row_array();
   	$data['title']='燕窝导购';
   	
    $map['status']=10;
    $map['id']=2;
	$picture=$this->db->select('img_id')->where($map)->order_by('sort')->get('picture')->row_array();
	$data['picture']=$this->GetImg($picture['img_id']);
	
    $data['code']=false;
   	$this->show($data);
   	
   }
  
  
    public function getGoods(){
    $this->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file'));
    $index_goods=$this->cache->get('index_goods');
 
    if (!$index_goods){
    $list=$this->db->select('goods_id,url')->get('index_goods')->result_array();
   	foreach ($list as $k=>$v){
   	$list[$k]['url']='https://'.$_SERVER['HTTP_HOST'].'/'.$v['url'];
     	}
    $this->cache->save('index_goods', $list,86400);
        }else {
    $list=$index_goods;
        }
        
    return $list; 	
    }
   
    public function article(){
		$data=$this->db->get('article')->result_array();
    	$this->show($data);
    }
   

}